#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;

namespace bytedance{
namespace April_22_2022{
    class solve_bytedance_4_24_zkm{
    public:
        solve_bytedance_4_24_zkm() {
            string name;
            segments.resize(4);
            get_data(name);
            for(string str:solve(name))cout<<str<<endl;
        }

        vector<int> segments;
        vector<string> answers;
        void get_data(string &str){
            str = "101b023a";
        }
        // s中不存在字母
        void dfs(const string & s,int cur_seg, int cur_idx){
            if(cur_seg==4){
                if(cur_idx==s.size()){
                    string res;
                    for(int i=0;i<4;++i){
                        res += to_string(segments[i]);
                        if(i!=3){
                            res += '.';
                        }
                    }
                    answers.push_back(res);
                }
                return;
            }
            if(cur_idx==s.size())return;
            if(s[cur_idx]=='0'){
                segments[cur_seg] = 0;
                dfs(s, cur_seg+1, cur_idx+1);
                return;
            }
            int val = 0;
            for(int i=cur_idx;i<s.size();++i){
                val *= 10;val += s[i]-'0';
                if(val>=0&&val<256){
                    segments[cur_seg] = val;
                    dfs(s, cur_seg+1, i+1);
                }
                else break;
            }
        }

        void replace(string& s, int cur, vector<char>& arr, vector<vector<int>>& indexs){
            if(cur==arr.size()){
                dfs(s, 0, 0);
                return;
            }
            string temp = s;
            string k = "";
            for(int i=0;i<10;++i){
                char c = '0' + i;
                // 替换所有为arr[cur]的字符，继而继续加油
                for(int j:indexs[cur]){
                    s[j] = c;
                }
                // s.replace(arr[i], '0'+i);
                replace(s, cur+1, arr, indexs);
                s = temp;
                k = "";
            }
        }

        void help(string str) {
            string temp = str;
            unordered_map<char,int>sts;
            
            vector<vector<int>> indexs;
            for(int i=0;i<str.length();++i){
                char c = str[i];
                if(c>='0'&&c<='9')continue;
                if(sts.count(c)){
                    indexs[sts[c]].push_back(i);
                }else{
                    sts[c] = sts.size();
                    indexs.push_back({i}); 
                }
                
            }
            if(sts.size()==0){
                // cout<<str<<std::endl;
                dfs(str,0,0);return;
            }
            vector<char> arrs(sts.size());
            for(auto c:sts){
                arrs[c.second] = c.first;
            }

            replace(str, 0, arrs, indexs);
        }

        vector<string> solve(string &str){
            help(str);
            return answers;
        }
    };
}
}